Networking
Firebase
Firebase is a set of hosting services for any type of application. It offers NoSQL and real-time hosting of databases, content, social authentication, and notifications, or services, such as a real-time communication server. I am able to send data from the ESP32 to firebase as well as read the firebase from the ESP32. Setting up the firebase database:- Go to firebase
- Create an account
- Create a new project
- Go to Authentication
- Click get started
- Use Email and Password
- Go to realtime database
- Create realtime database
- Choose test mode, can change later
- Save the URL
- Go to project settings
- Save Web API Key
- Now its time to start coding in Arduino
Starting to code in Arduino:
- Go to Manage Libraries
- Install Firebase Arduino Client Library for ESP8266 and ESP32 by Mobitz
- In the code make sure to include the libraries for Wifi and Firebase_ESP_Client
- When inputing wifi SSID and password, computer must be on the same internet, Harvard Wifi does not work
- Then set your API Key and Database URL which we copied before
Sending data: Set Function Then using the set function, we can set a specific path in our firebase database to an int, float, double, string, JSON, array, blob, or file.
- set
- setInt
- setFloat
- setDouble
- setBool
- setString
- setJSON
- setArray
- setBlob
- setFile
The specific path in the database is important because when we are trying to get the data from the database we need to use that same path. I am also able to create a web app that displays the numbers on a URL. Recieivng data: Get Function
The get function, we can get the int, float, double, string, JSON, array, blob, or file from a specific path in the database by using the get functions.
- get
- getInt
- getFloat
- getDouble
- getBool
- getString
- getJSON
- getArray
- getBlob
- getFile
- Open a new VS Code window
- go to the correct directory the in the terminal
- Type firebase init
- Select Realtime database and Hosting by hitting space
- Use existing project
- Hit enter twice
- Type N twice
Link to the webpage
With ESP32: I set the wifi, and firebase authentication and host. Then set up the strings which we are looking for on firebase. Then we start looking towards the path which we set to have the information. With HTML and Javascript: I set the path which to store the data. Then I made buttons which will change the data in the database. The ESP32 board will then read the database and change accordingly.